home *** CD-ROM | disk | FTP | other *** search
/ Graphics & Sound Program…ng Techniques for the Mac / Graphics and Sound Programming Techniques for the Mac.iso / M&T Graphics & Sound Examples / Symantec Versions / C07 QuickTime Movies / P01 Quick Play Movie / QuickPlay.c next >
Encoding:
C/C++ Source or Header  |  1995-08-31  |  2.4 KB  |  102 lines  |  [TEXT/KAHL]

  1. //____________________________________________________________
  2. //    QuickPlay.c
  3. //
  4. //    Copyright © Dan Parks Sydow, 1995
  5. //    From the book:
  6. //    "Graphics and Sound Programming Techniques for the Mac",
  7. //    M&T Books, 1995
  8.  
  9.  
  10. //____________________________________________________________
  11.  
  12. #include <Movies.h>   
  13.  
  14.  
  15. //____________________________________________________________
  16.  
  17. void  InitializeAllToolboxes( void );
  18.  
  19.  
  20. //____________________________________________________________
  21.  
  22. #define      rMovieWindow            128
  23. #define      kMovieName         "\pRobot"
  24.  
  25.  
  26. //____________________________________________________________
  27.  
  28. void  main( void )
  29.    OSErr      theError;
  30.    FSSpec     theFSSpec;
  31.    short      theFileRefNum;
  32.    Movie      theMovie;
  33.    short      theMovieResID = 0;   
  34.    Str255     theMovieResName;
  35.    Boolean    wasAltered;
  36.    WindowPtr  theWindow;
  37.    Rect       theMovieBox;
  38.  
  39.    InitializeAllToolboxes();
  40.    
  41.    theError = FSMakeFSSpec( 0, 0, kMovieName, &theFSSpec );
  42.    theError = OpenMovieFile( &theFSSpec, &theFileRefNum, fsRdPerm );
  43.    theError = NewMovieFromFile( &theMovie, theFileRefNum, &theMovieResID,
  44.                                  theMovieResName, newMovieActive, &wasAltered );
  45.                                          
  46.    CloseMovieFile( theFileRefNum );
  47.    
  48.    theWindow = GetNewCWindow( rMovieWindow, nil, (WindowPtr)-1L );   
  49.  
  50.    SetMovieGWorld( theMovie, (CGrafPtr)theWindow, nil );   
  51.  
  52.    GetMovieBox( theMovie, &theMovieBox );
  53.    OffsetRect( &theMovieBox, -theMovieBox.left, -theMovieBox.top );
  54.    SetMovieBox( theMovie, &theMovieBox );
  55.  
  56.    SizeWindow( theWindow, theMovieBox.right, theMovieBox.bottom, true );  
  57.    ShowWindow( theWindow);
  58.  
  59.    GoToBeginningOfMovie( theMovie );
  60.  
  61.    StartMovie( theMovie );
  62.  
  63.    do
  64.    {
  65.       MoviesTask(theMovie, 0);
  66.    }
  67.    while ( IsMovieDone( theMovie ) == false );
  68.    
  69.    DisposeMovie( theMovie );
  70.    DisposeWindow( theWindow );
  71. }
  72.  
  73.  
  74. //____________________________________________________________
  75.  
  76. void  InitializeAllToolboxes( void )
  77. {
  78.    OSErr  theError;
  79.    long   theResult;
  80.  
  81.    InitGraf( &qd.thePort );
  82.    InitFonts();
  83.    InitWindows();
  84.    InitMenus();
  85.    TEInit();
  86.    InitDialogs( 0L );
  87.    FlushEvents( everyEvent, 0 );
  88.    InitCursor();
  89.  
  90.    theError = Gestalt( gestaltQuickTime, &theResult );
  91.    if ( theError != noErr )
  92.       ExitToShell();
  93.                                                  
  94.    theError = EnterMovies();  
  95.    if ( theError != noErr )
  96.       ExitToShell(); 
  97. }
  98.  
  99.  
  100.  
  101.